package com.example.demo.niuke;

import java.util.*;
import java.util.stream.Collectors;

/**
 * @Author: liull
 * @Description: 有一个字符串List，如下代码所示。续写代码，将words中的元素再按照字符拆分，
 * 合并成一个数组，然后字符去重，最终得到["h", "e", "l", "o", "w", "r", "d"]
 * @Date: Created in 14:30 2020/4/12
 * @Modified By:
 */
public class Main52 {
    public static void main(String[] args) {
        List<String> words = new ArrayList<>();
        words.add("hello");
        words.add("world");
        String s = words.stream().collect(Collectors.joining());
        String[] strings = s.split("");
        HashSet<String> set = new LinkedHashSet<>();
        for (String ss : strings) {
            set.add(ss);
        }
        System.out.println(Arrays.toString(set.toArray()));
    }
}
